<div class="main_content w1200">
    <!--商品购买-第一层结构-->
    <div class="buy_block_one">
        <!--商品视图-->
        <div class="viewport fl">
            <div id="imageZooms" class="view" style="position: relative;">
              <?php if($goods_info['pics']):?>
                <img src="<?=$goods_info['pics'][0]?>">
              <?php else:?>
                <img src="<?=$goods_info['pic']?>">
              <?php endif;?>
                <div class="imageMask" style="width: 198px; height: 198px; border: 1px solid rgb(170, 170, 170); background: rgb(240, 240, 240); opacity: 0.5; position: absolute; cursor: crosshair; z-index: 110; display: none; left: 198px; top: 198px;"></div>
            </div>
            <div class="sort_view">
                <ul class="wrap">
                  <?php if($goods_info['pics']):?>
                    <?php foreach($goods_info['pics'] as $k=>$v): ?>
                      <li <?php if($k == 0):?> class="cur" <?php endif;?>><img src="<?=$v?>"></li>
                    <?php endforeach;?>
                <?php else:?>
                  <li class="cur"><img src="<?=$goods_info['pic']?>"></li>
                <?php endif;?>
                </ul>
            </div>
        </div>
        <!--商品购买-->
        <div class="product fl">
            <!--商品标题-->
            <input type="hidden" id="goods_id" value="<?=$goods_info['id']?>" />
            <div class="prod_nameX">
                <h3 class="top_title"><?=$goods_info['title']?></h3>
                <p class="under_title"><?=$goods_info['description']?></p>
            </div>
            <!--商品标题-->
            <div class="prod_priceX">
                <span class="placeholder">价格：</span>
                <span class="price">
                    <em></em>
                    <font id="goodsPrice">￥<?=$goods_info['p_price']?></font>
                </span>
                <div class="prod_eval fr">
                    <span class="eval_span cur"><strong><?=count($comment);?></strong><em>累计评论</em></span>
                    <span class="eval_span cur"><strong><?=$goods_info['sales_volume']?></strong><em>累计销量</em></span>
                    <span class="eval_span"><strong><?=$goods_info['p_stock']?></strong><em>库存</em></span>
                </div>
            </div>
            <div class="prod_service">
                <span class="placeholder">温馨提示：</span>
                <p class="service"><?=$com['word']['wxts']['content']?></p>
            </div>
            <!--商品规格和数量-->
            <div class="prod_dl">
                <?php foreach($spec as $k=>$v): ?>
                <dl class="type">
                    <dt><?=$k?>：</dt>
                    <dd class="fl">
                        <?php foreach($v as $key=>$val): ?>
                        <a href="javascript:;" onclick="select_attr(this,<?=$goods_info['goods_id']?>)" class="<?=$val[1]?'cur':'';?>"><?=$val[0]?></a>
                        <?php endforeach; ?>
                    </dd>
                </dl>
                <?php endforeach; ?>
                <!--用户购买数量-->
                <dl class="prod_add">
                    <dt>数量</dt>
                    <dd>
                        <div class="add">
                            <a href="javascript:;" onclick="editBuyNum('cut')" class="numJian numbtn">-</a>
                            <input id="buyCarNum"  type="text" value="1" class="numText" maxlength="3">
                            <a href="javascript:;" onclick="editBuyNum('add')" class="numJia numbtn">+</a>
                        </div>
                        <div class="goodsSkuStock">运费：<span id="goodsSkuStock">￥<?=$goods_info['postage']?></span></div>
                    </dd>
                </dl>
                <!--用户购买数量-->
            </div>
            <!--商品规格和数量-->
            <!--商品购买操作-->
            <div class="prod_buys">
                <a href="javascript:;" onclick="addgoodscart()" class="buy_btn prod_car"><i></i>加入购物车</a>
                <a href="javascript:;" onclick="buyNow()" class="buy_btn prod_buy">立即购买</a>
            </div>
            <!--商品购买操作-->
            <!--商品保障-->
            <div class="prod_msg" oncontextmenu="return false"> <span>保障</span>
                <ul class="ensure">
                    <li> <i></i><span class="ensure_font">正品保障</span> </li>
                    <li> <i></i><span class="ensure_font">售后无忧</span> </li>
                </ul>
            </div>
            <!--商品购买-->
        </div>
        <!--相关商品-->
        <div class="right fr">
            <!--相关标题-->
            <div class="fr_tit">同分类商品</div>
            <!--相关集合-最多输出3个-->
            <ul class="fr_ul">
                <?php foreach($cat_goods as $k=>$v):?>
                <li>
                    <a href="<?=url('goods/detail',['id'=>$v['id']])?>"><img src="<?=$v['pic']?>"></a>
                    <div class="info">
                        <p class="name"><a href="<?=url('goods/detail',['id'=>$v['id']])?>"><?=$v['title']?></a></p>
                        <p class="price">￥<?=$v["price"]?></p>
                    </div>
                </li>
                <?php endforeach;?>

            </ul>
            <!--相关集合-->
        </div>
        <!--相关商品-->
    </div>
    <div class="buy_animate"></div>
    <!--商品购买-第一层结构end-->
    <!--商品购买-第二层结构srar-->
    <div class="buy_block_two">
        <!--右模块-->
        <div class="prodpar_left fl">
            <!--店铺-->

            <!--店铺end-->
            <!--相关商品-->
            <?php include_once __DIR__.'/../inc/footpoint.html';?>

        </div>
        <!--相关商品end-->
        <!--右模块end-->
        <!--左模块end-->
        <div class="prodpar_right fr">
            <!--切换按钮edn-->
            <div class="ulhead">
                <ul>
                    <li class="cur"><a href="javascript:;" tabindex="1">商品介绍</a></li>
                    <li class=""><a href="javascript:;" tabindex="2">评价<span>(<?=count($comment)?>)</span></a></li>
                    <li class=""><a href="javascript:;" tabindex="3">售后服务</a></li>
                </ul>
            </div>
            <!--切换按钮edn-->
            <!--切换卡end-->
            <div class="switch_card">
                <!--切换卡1-->
                <div class="switch_item">
                    <!--商品参数块-->
                    <div class="prod_parem">
                        <h3>规格参数</h3>
                        <ul class="parWrap">
                            <?=$goods_info['attr']?>
                        </ul>
                    </div>
                    <!--商品参数块-->
                    <div class="IMage">
                        <?=$goods_info['content']?>
                    </div>
                    <!--商品详情图-->
                </div>
                <!--卡1-->
                <!--卡2-->
                <div class="switch_item" style="border-bottom:none">
                    <!--累计评价-->
                    <h2>累计评价<span>(<?=count($comment);?>)</span></h2>
                    <div class="user_comment">
                        <ul class="comment">
                        <?php foreach($comment as $v):?>
                            <li>
                                <dl>
                                    <dt><?=$v['username']?></dt>
                                    <dd><?=$v['content']?></dd>
                                </dl>
                            </li>
                        <?php endforeach;?>
                        </ul>
                    </div>
                    <!--累计评价-->
                </div>
                <!--卡2-->
                <!--卡3-->
                <div class="switch_item">
                    <!--服务条款-->
                    <h2>售后服务</h2>
                    <div class="insert_prod">
                        <div class="prod_font">
                            <?=$com['word']['shfw']['content']?>
                        </div>
                    </div>
                    <!--服务条款-->
                </div>
                <!--卡3-->
            </div>
            <!--切换卡-->
        </div>
        <!--F坐模块-->
    </div>
    <!--商品购买-第二层结构-->
</div>
<!--main-->

<!--弹出层-->
<div id="alert" class="rewrite_alert" style="display:none">
    <div class="Transparent_layer"></div>
    <div class="alert">
        <div class="head"> <span class="tit">系统提示</span> <span class="CloseDialogBox" title="关闭"></span> </div>
        <div class="body" id="Warnwrods"> Not Found Object! </div>
        <div class="down"> <a href="javascript:;" onclick="warn_sure(this)" class="confirm" id="WarnConfrim">确定</a> <a href="javascript:;" onclick="" class="cancel">取消</a> </div>
    </div>
</div>
<div id="cart_alert" class="rewrite_alert" style="display:none">
    <div class="Transparent_layer"></div>
    <div class="alert">
        <div class="head"> <span class="tit">系统提示</span> <span class="CloseDialogBox" title="关闭"></span> </div>
        <div class="body" id="Warnwrods"> 添加购物车成功！ </div>
        <div class="down"> <a href="<?=url('user/myCart')?>"  class="confirm" id="WarnConfrim">前往购物车</a> <a href="javascript:;" onclick="" class="cancel">关闭</a> </div>
    </div>
</div>
<!--弹出层-->
<script type="text/javascript">
$(function() {
    imageZoom({
        imageZoomBox: '#imageZooms'
    });
    $('.cancel,.confirm,.CloseDialogBox').click(function () {
        $('.rewrite_alert').hide();
    });
    //页面滚动，锚链接显示
    $(window).scroll(function(){
        var Scroll=document.documentElement.scrollTop||document.body.scrollTop;
        var scrollVal=500;
        if(Scroll>=scrollVal){
            $('.Anchor_top').fadeIn(300);
        }else{
            $('.Anchor_top').fadeOut(300);
        }
    });
    $('.Anchor_top').click(function(){
        $(document.body).animate({scrollTop:0},200);
    });
    //锚点
    var getOffset=$('.ulhead').get(0).offsetTop;
    $(window).scroll(function(){
        if($(window).scrollTop()>=getOffset){
            $('.ulhead').addClass('is');
        }else{
            $('.ulhead').removeClass('is');
        }
    });
    $('.ulhead').find('li').eq(0).click(function(){
        setOffset('.prodpar_right');
    });
    $('.ulhead').find('li').eq(1).click(function(){
        setOffset('.user_comment');
    });
    $('.ulhead').find('li').eq(2).click(function(){
        setOffset('.insert_prod');
    });
});

//选择规格
function select_attr(obj,goods_id){
    var price = $(obj).data("price");
    $(obj).siblings().removeClass("cur");
    $(obj).addClass("cur");
    var title = "";
    $(".prod_dl .type .fl .cur").each(function(j,item){
        title += "_" + $(item).html();
    });
    console.log({'title': title, "goods_id": goods_id});
    $.ajax({
        url: "<?=url('goods/findgoods')?>",
        method: "post",
        data: {'title': title, "goods_id": goods_id},
        dataType: "JSON",
        success: function (d) {
            if (d.code == 0) {
                window.location.href = d.js.url;
            } else {
                layer.msg("没找到商品");
            }
        }
    });
}
//添加商品至购物车
function addgoodscart() {
    var attr_id = <?=$_GET['gid']?>;
    if (!attr_id) {
        attr_id = 0;
    }
    var nums = $("#buyCarNum").val();
    $.ajax({
        url: "<?=url('goods/addCart')?>",
        method: "post",
        data: {'attr_id': attr_id,  "nums": nums},
        dataType: "JSON",
        success: function (d) {
            if (d.code == 100) {
                warn(d.msg);
            } else {
                $("#cart_alert").show();
                $("#buyCarMenu").html(d.data.count);
            }
        }
    });
}
function setOffset(obj){
    console.log(obj);
    $('html,body').animate({scrollTop:getOffset(obj)},640);
}
function getOffset(obj){
    return $(obj).get(0).offsetTop;
}
//立即购买
function buyNow(){
    var attr_id = <?=$_GET['gid']?>;
    if(!attr_id){
        attr_id = 0;
    }
    var nums = $("#buyCarNum").val();
    $.ajax({
    url:"<?=url('goods/addCart')?>",
        method:"post",
        data:{'attr_id':attr_id, "nums":nums},
        dataType:"JSON",
        success:function(res){
            if(res.code == 100){
                warn(res.msg);
            }else{
                my.action(res);
            }
        }
    });
}
function warn_sure(e){
    <?php if($c!='publics' && !$userinfo):?>
    window.location.href = "/publics/login";
    <?php endif;?>
}
</script>
